package com.xinghou.platform.util;

/**
 * Created by qingshengzheng on 16/8/25.
 */
public class EmojiFilterUtil {
    /**
     * 将emoji表情替换成*
     *
     * @param source
     * @return 过滤后的字符串
     */
    public static String filterEmoji(String source) {
        if(StringUtils.isNotBlank(source)){
            return source.replaceAll("[\\ud800\\udc00-\\udbff\\udfff\\ud800-\\udfff]", "*");
        }else{
            return source;
        }
    }

    public static void main(String[] arg ){
        try{
            String text = "nickname\":\"WAN\uD83D\uDC83\uD83C\uDFFB忆\uD83D\uDC9E 莲\uD83D\uDC8B\" ";
            System.out.println(text);
            System.out.println(text.length());
            System.out.println(text.replaceAll("[\\ud83c\\udc00-\\ud83c\\udfff]|[\\ud83d\\udc00-\\ud83d\\udfff]|[\\u2600-\\u27ff]", "*"));
            System.out.println(filterEmoji(text));
        }catch (Exception ex){
            ex.printStackTrace();
        }
    }



}
